<?php if( !empty($data) ){ ?>
    <div class="table-responsive">
        <table  class="table table-striped table-bordered" style=" margin-top:3rem;"  >
            <thead>
            <tr>
                <th style="text-align: center" width="35%">消息内容</th>
                <th style="text-align: center" >时间</th>
                <th style="text-align: center" >是否已读</th>
                <th style="text-align: center" >操作</th>
            </tr>
            </thead>
            <tbody>
            <?php foreach( $data as $k => $v ){ ?>
            <tr data_id="<?php echo $v['id']; ?>" >
                <td>
                    <a href="/home/message/content?type=2&id=<?php echo $v['id']; ?>" class="up_readStatus">
                        <?php echo substr( $v['message'], 0,21 ).'...'; ?>
                    </a>
                </td>
                <td style="text-align: center" > <?php echo date( 'Y/m/d H:i:s', $v['create_time'] ); ?> </td>
                <td style="text-align: center" id="read_<?php echo $v['id']; ?>">
                    <?php if ( $v['status_read'] == 1 ){ ?> 未阅读
                    <?php } else { ?> 已阅读
                    <?php } ?>
                </td>
                <td style="text-align: center"> <span class="del_message">删除</span> </td>
            </tr>
            <?php } ?>

            <!--<tr><td  colspan=6 align='center'><?php echo $page;?></td><tr>-->
            </tbody>
        </table>
    </div>
<?php } else { ?>
    <div class="table-responsive">
        <table  class="table table-striped table-bordered" style=" margin-top:3rem; text-align: center" >
            暂无消息。。。
        </table>
    </div>
<?php }?>


<script type='text/javascript'>
    $(".del_message").click(function(){
        if ( !confirm("您确定要删除么？") ){
            return false;
        }
        var that = $(this);
        var data_id = $(this).parents("tr").attr("data_id");
        $.ajax({
            url: "/home/message/setDel",
            data: "id="+data_id,
            type: "POST",
            async: true,
            success: function (data) {
                if ( data == 'false') {
                    return false;
                }
                // alert( data );
                that.parents( "tr" ).empty();
                // 刷新本页面
                window.location.reload();
            }
        });
    })

    $(".up_readStatus").click(function(){
        var edi = $(this).parent("td").next().next().html().replace(/(^\s*)|(\s*$)/g, "");
        if ( edi == "未阅读" ){
            $(this).parent("td").next().next().html("已阅读");
        }
    });
</script>
